package com.zhlb.zfba.modules.card.service;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhlb.zfba.common.utils.DateUtil;
import com.zhlb.zfba.common.utils.IdGen;
import com.zhlb.zfba.modules.card.bean.CardRegInfo;
import com.zhlb.zfba.modules.card.dao.CardRegInfoDao;
import com.zhlb.zfba.modules.per.bean.PoliceInfo;

@Service
public class CardRegInfoService {
	@Autowired 
	CardRegInfoDao cardRegInfoDao;
	public CardRegInfo get(String id) {
		return cardRegInfoDao.get(id);
	}
	public CardRegInfo getByCardNo(CardRegInfo cardRegInfo) {
		return cardRegInfoDao.getByCardNo(cardRegInfo);
	}
	
	public List<CardRegInfo> findList(CardRegInfo cardRegInfo) {
		return cardRegInfoDao.findList(cardRegInfo);
	}
	
	@Transactional(readOnly = false)
	public void save(CardRegInfo cardRegInfo) {
		if(StringUtils.isBlank(cardRegInfo.getCardID())){
			cardRegInfo.setCardID(IdGen.uuid());
			cardRegInfo.setCreateDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"));
			cardRegInfoDao.insert(cardRegInfo);
			
		}else{
			cardRegInfoDao.update(cardRegInfo);
		 }
	}
	
	@Transactional(readOnly = false)
	public void delete(String ids) {
		String[] idArr=null;
		if(StringUtils.isNotBlank(ids)){
			idArr=ids.split(",");
			for(String id:idArr){
				cardRegInfoDao.delete(id);
			}
		}
		
	}

}
